<?php
/*
// @author : lael
// blog : http://hi.baidu.com/lael80
// http://www.gzyd.net
// all right reserved.
*/

namespace ydsdk\controllers\admin;

class login extends \ydsdk\core\admin {	
	public function __construct(){
		parent::__construct();
	}

	public function index(){
		if(issubmit()){
			if(!$_POST['email'] || !$_POST['password']){
				exitjson(-1, '账号与登录不能为空');
			}
			$row = $this->db->get_row('admin', '*', array('email' => $_POST['email'], 'password' => $_POST['password']));
			if(!$row)exitjson(-1, '账号不存在或密码错误');
			$_SESSION['admin'] = $row;
			exitjson(1, '登录系统成功');	
		}
		$this->smarty->display('login.html');
	}
	
	public function logout(){
		$_SESSION['admin'] = null;
		unset($_SESSION['admin']);
		redirect(array('con' => 'admin/login'));
	}
}
